from django.contrib import admin

import polls.models as models


class ChoiceInline(admin.TabularInline):
    model = models.Choice
    extra = 3


#  admin.TabularInline 表单行
#  admin.StackedInline 表换行

class QuestionAdmin(admin.ModelAdmin):
    # fields = ["question_text", "pub_date"]
    fieldsets = [
        ("问题本质", {"fields": ["question_text"]}),
        ("日期信息", {"fields": ["pub_date"],"classes": ["collapse"]}),
    ]
    # "classes": ["collapse"] 在fields里面可以进行一个隐藏的样式
    inlines = [ChoiceInline]
    # list_display = ["question_text", "pub_date"]
    list_display = ["question_text", "pub_date", "was_published_recently"] #哪些字段进行相对应的展示
    list_filter = ["pub_date", "question_text"]  #可以在管理页面通过什么字段来查询一些范围


admin.site.register(models.Question, QuestionAdmin)
admin.site.register(models.Choice)
